<template>
  <div>
    <div class="top">
      <router-link to="/home/interview">返回</router-link>
      <div class="dt">面经详情</div>
      <div></div>
    </div>
    <h1>{{ obj.stem }}</h1>
    <div class="info">
      <span>{{ obj.createdAt }}</span>
      <span>|</span>
      <span>{{ obj.views }} 浏览量</span>
      <span>|</span>
      <span>{{ obj.likeCount }} 点赞数</span>
    </div>

    <div class="qian">
      <img :src="obj.creatorAvatar" alt="" />
      <span>{{ obj.creatorName }}</span>
    </div>

    <div class="content" ref="content">
      {{ obj.content }}
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      obj: {},
    };
  },
  name: "HmDetail",
  methods: {
    async getDetail(id) {
      if (!id) return;
      const res = await axios({
        url: "http://interview-api-t.itheima.net/admin/interview/show",
        params: { id },
        //传token
        headers: {
          Authorization: `Bearer ${localStorage.getItem("token")}`,
        },
      });
      console.log(res.data);
      this.obj = res.data.data;
    },
  },
  created() {
    this.getDetail(this.$route.params.id);
  },
};
</script>

<style lang="less" scoped>
.qian {
  display: flex;
  align-items: center;
  img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
  }
}
.top {
  display: flex;
  width: 100%;
  background-color: #00bed0;

  justify-content: space-between;

  .dt {
    align-self: center;
  }
}
.content {
  text-indent: 2em;
}
</style>
